﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class UserControls_DepositRecord :UCBase 
{
    public UserControls_DepositRecord()
    {
        Name = "预存款记录";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["RecordType"] == null || Session["RecordType"].ToString() == "Deposit")
        {
            this.DepRecord.Visible = true;
            this.PayRecord.Visible = false;
            this.Deposit.Style.Add("background-image", "url(images/button_user_1.jpg)");
            this.Pay.Style.Add("background-image", "url(images/bg_gold_23_2.jpg)");
        }
        else
        {
            this.PayRecord.Visible = true;
            this.DepRecord.Visible = false;
            this.Pay.Style.Add("background-image", "url(images/button_user_1.jpg)");
            this.Deposit.Style.Add("background-image", "url(images/bg_gold_23_2.jpg)");
        }
        if (_Customer == null)
        {
            Response.Redirect("Default.aspx?PN=Login");
        }
        else
        {
            LoadDepositRecord();
            LoadPayRecord();
            LoadLabel();
        }
            
    }

    /// <summary>
    /// 绑定充值记录
    /// </summary>
    private void LoadDepositRecord()
    {
        this.Page1.FindType = 0;
        this.Page1.Field1 = "";
        this.Page1.Field2 = "";
        this.Page1.Like1 = "";
        this.Page1.Like2 = "";
        Page1.GridID = gvDepRecord;
        Page1.TableName = "V_GetDepositRecord";
        Page1.Condition = "where CustomerID=" + _Customer.ID + " and (OperatorType=1 or OperatorType=2 or OperatorType=4)";
        
    }

    /// <summary>
    /// 绑定支付记录
    /// </summary>
    private void LoadPayRecord()
    {
        this.Page2.FindType = 0;
        this.Page2.Field1 = "";
        this.Page2.Field2 = "";
        this.Page2.Like1 = "";
        this.Page2.Like2 = "";
        Page2.GridID = gvPayRecord;
        Page2.TableName = "V_GetDepositRecord";
        Page2.Condition = "where CustomerID=" + _Customer.ID + " and OperatorType=3";
       
    }

    /// <summary>
    /// 加载总的充值金额，支付金额，剩余金额
    /// </summary>
    private void LoadLabel()
    {
        //DataTable dt = BLL.DepositRecordBLL.GetDepositRecord("CustomerID=" + ((Entity.Customer)_Customer).Id + "");
        
        //if (dt != null && dt.Rows.Count > 0)
        //{
        //    DataRow dr = dt.Rows[0];
        //    lbSum.Text = dr["totalPaySum"].ToString();
        //    lbRemainMoney.Text = dr["RemainSum"].ToString();
        //    lbRemainSum.Text = dr["RemainSum"].ToString();
        //    lbSumMoney.Text = dr["totalDepSum"].ToString();
        //}
    }
    protected void gvDepRecord_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //绑定表格样式
        e.Row.Attributes.Add("class", "black12");
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Style.Add("background-image", "url(images/bg_hui_23_2.jpg)");
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.BackColor = System.Drawing.Color.FromName("#FFFFFF");
        }
    }
    protected void gvPayRecord_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //设置表格样式
        e.Row.Attributes.Add("class", "black12");
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Style.Add("background-image", "url(images/bg_hui_23_2.jpg)");
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.BackColor = System.Drawing.Color.FromName("#FFFFFF");
        }
    }
    protected void lbDepositRecord_Click(object sender, EventArgs e)
    {
        Session["RecordType"] = "Deposit";
        this.DepRecord.Visible = true;
        this.PayRecord.Visible = false;
        this.Deposit.Style.Add("background-image", "url(images/button_user_1.jpg)");
        this.Pay.Style.Add("background-image", "url(images/bg_gold_23_2.jpg)");
     }
    protected void lbPayRecord_Click(object sender, EventArgs e)
    {
        Session["RecordType"] = "Pay";
        this.PayRecord.Visible = true;
        this.DepRecord.Visible = false;
        this.Pay.Style.Add("background-image", "url(images/button_user_1.jpg)");
        this.Deposit.Style.Add("background-image", "url(images/bg_gold_23_2.jpg)");
     }
}
